using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.EventSystems;

namespace Super
{
	[RequireComponent(typeof(Collider2D))]
	public class SpriteBtn : MonoBehaviour
	{
		private Vector3 oriScale;
		public Vector3 scale = new Vector3(0.9f, 0.9f, 0.9f);
		public bool isEnter;
		public Action action;

		private void Start()
		{
			oriScale = transform.localScale;
		}

		private void OnMouseUp()
		{
			if (EventSystem.current.IsPointerOverGameObject()) return;
			if (!isEnter) return;

			transform.localScale = oriScale;
			LogUtil.Log(LogType.Normal, LogCategory.Default, "OnClick");
			action?.Invoke();
		}

		private void OnMouseExit()
		{
			isEnter = false;
			transform.localScale = oriScale;
		}

		private void OnMouseDown()
		{
			if (EventSystem.current.IsPointerOverGameObject()) return;
			
			transform.localScale = Vector3.Scale(oriScale, scale);
		}

		private void OnMouseEnter()
		{
			isEnter = true;
		}
	}



}
